<!DOCTYPE html>
<html lang="en" ng-app="taskList">
<head>
	<meta charset="UTF-8">
	<title>第一个angular小程序</title>
	<link rel="stylesheet" type="text/css" href="../resources/bootstrap/css/bootstrap.min.css">
</head>
<body style="padding:20px;" ng-controller="addTask">
	<div class="input-group">
		<input type="text" class="form-control" ng-model="task">
		<span class="input-group-btn">
			<button class="btn btn-default" ng-click="add()">提交</button>
		</span>
	</div>
	<h4 ng-if="taskArr.length>0">任务列表</h4>
	<ul class="list-group">
		<li class="list-group-item" ng-repeat="item in taskArr track by $index">
			{{item}}
			<a ng-click="taskArr.splice($index,1)">删除</a>
		</li>
	</ul>
</body>
<script type="text/javascript" src="../resources/angular/angular.min.js"></script>
<script type="text/javascript">
	angular.module('taskList', [])
	.controller("addTask",function($scope){
		$scope.task="";
		$scope.taskArr=[];
		$scope.add=function(){
			$scope.taskArr.push($scope.task);
		}
	});
	
</script>
</html>